
<style>
    .left{background-color: rgba(228, 228, 228, 1);}
    .img_div{text-align: center; margin-top: 20px;}
    .img_div img{width: 100px;height: 100px;margin-bottom:20px;}
    .bottom_line{border-bottom: 1px solid black;}
</style>
<div class="box">
    <div class="box-header with-border">
        <h3 class="box-title">内容详情</h3>
        <div class="box-tools pull-right">
            <div class="btn-group pull-right" style="margin-right: 10px">
                <a class="btn btn-sm btn-primary grid-refresh" title="刷新"><i class="fa fa-refresh"></i><span class="hidden-xs"> 刷新</span></a>
            </div>
            <div class="btn-group pull-right" style="margin-right: 10px">
                <a href="/statistics/community" class="btn btn-sm btn-default" title="列表"><i class="fa fa-list"></i><span class="hidden-xs">&nbsp;返回</span></a>
            </div>
        </div>
    </div>
    <div class="box-body" style="display: block;">
        <div class="col-md-2">
            <div class="img_div">
                @if($data['user'])
                    <img src="{{get_img($data['user']['avatar'])}}">
                @endif
                <br>
                <span>
                    @if($data['user'])
                        {{$data['user']['username']}}
                    @endif
                </span>
            </div>
            <div style="margin-top: 30px;">
                <table class="table">
                    <tbody>
                    <tr>
                        <td>标题：</td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>分类：</td>
                        <td>附近</td>
                    </tr>
                    <tr>
                        <td>日期：</td>
                        <td>{{@$data['create_at']}}</td>
                    </tr>
                    <tr>
                        <td>IP地址：</td>
                        <td></td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="col-md-10">
            <div class="head bottom_line">
                <span>礼物</span>
                <span>{{@$data['gift_num']}}</span>
                <span>阅读</span>
                <span>{{@$data['page_view']}}</span>
            </div>
            <div class="content">
                {{@$data['content']}}
            </div>
            <div class="img">
                @foreach(explode(',', @$data['images']) as $v)
                    <img style="max-width: 800px;" src="{{get_img($v)}}" alt="">
                @endforeach
            </div>
            <div class="bottom_line"><span>回复此内容</span></div>
            <div>
                <form id="reply" class="form-horizontal">
                    <div class="box-body">
                        <div class="fields-group">
                            <div class="form-group">
                                <label for="name" class="col-sm-2  control-label">用户名：</label>
                                <div class="col-sm-8">
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="fa fa-pencil fa-fw"></i></span>
                                        <input type="text" id="name" name="name" value="{{Admin::user()->username}}" class="form-control name" placeholder="输入 用户名">
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="telephone" class="col-sm-2  control-label">手机号：</label>
                                <div class="col-sm-8">
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="fa fa-pencil fa-fw"></i></span>
                                        <input type="text" id="telephone" name="telephone" value="" class="form-control telephone" placeholder="输入 手机号">
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="content" class="col-sm-2  control-label">回复内容：</label>
                                <div class="col-sm-8">
                                    <textarea name="content" class="form-control content" rows="5" placeholder="输入 回复内容"></textarea>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- /.box-body -->
                    <div class="box-footer">
                        <input type="hidden" name="community_id" value="{{@$data['community_id']}}">
                        <input type="hidden" name="_token" value="{{csrf_token()}}">
                        <div class="col-md-2">
                        </div>

                        <div class="col-md-8">
                            <div class="btn-group pull-left">
                                <button type="submit" class="btn btn-primary">提交</button>
                                <span style="line-height: 34px; padding-left: 10px;">注意：管理员回复内容会在前台显示</span>
                            </div>
                        </div>
                    </div>
                    <!-- /.box-footer -->
                </form>
            </div>

            <div class="bottom_line"><span>礼物列表</span></div>

            <div>
            @foreach($data['gifts'] as $gift)
                <div style="height: 100px;overflow:hidden; padding: 10px; border-bottom: 1px solid #f4f4f4">
                    <div class="col-md-2">
                        <div>
                            <img class="avatar" src="{{get_img($gift['avatar'])}}" alt="" style="width: 50px; height: 50px;" >
                        </div>
                    </div>
                    <div class="col-md-6">
                        <p>{{@$gift['username']}}</p>
                        <p>{{@$gift['tag_name']}}</p>
                        <p>{{@$gift['create_at']}}</p>
                    </div>
                    <div class="col-md-4">
                        <img class="avatar" src="{{get_img($gift['gift_icon'])}}" alt="" style="width: 50px; height: 50px;">
                        <span style="font-size: 30px;">x {{@$gift['num']}}</span>
                    </div>
                </div>
            @endforeach
            </div>

            <div class="bottom_line"><span>全部评论 {{@$data['']}}</span></div>

            <div>
                <div id="box">
                    @foreach($data['comments']['data'] as $val)
                    <div style="min-height: 100px;overflow:hidden; padding: 10px; border-bottom: 1px solid #f4f4f4">
                        <div class="col-md-2">
                            <div>
                                <img class="avatar" src="{{get_img($val['user_icon'])}}" alt="" style="width: 50px; height: 50px;" >
                            </div>
                        </div>
                        <div class="col-md-10">
                            <p>{{@$val['user_name']}}</p>
                            <p>{{@$val['content']}}</p>
                            <p>{{@$val['create_at']}}</p>
                        </div>
                    </div>
                    @endforeach
                    <a href="javascript:void(0)" class="page" data-page="1">首页</a>
                    <a href="javascript:void(0)" class="page" data-page="{{$data['comments']['prev']}}">上一页</a>
                        @foreach($data['comments']['pp'] as $key=>$val)
                            @if($val == $data['comments']['page'])
                                {{$val}}
                            @else
                                <a href="javascript:void(0)" class="page" data-page="{{$val}}" >{{$val}}</a>
                            @endif
                        @endforeach
                    <a href="javascript:void(0)" class="page" data-page="{{$data['comments']['next']}}" >下一页</a>
                    <a href="javascript:void(0)" class="page" data-page="{{$data['comments']['sums']}}" >尾页</a><br />

                </div>
            </div>
        </div>
    </div>
</div>



<script>
    $(function () {
        $('#reply').on('submit', function (event) {
            event.preventDefault();

            $.ajax({
                method: 'post',
                url: '/community/addComment',
                data: $('#reply').serialize(),
                success: function (r) {
                    if (r.status){
                        swal(r.message, '', 'success');
                    } else {
                        swal(r.message, '', 'error');
                    }
                }
            });
        });


        $(".avatar").on("error", function () {
            $(this).attr("src", "../../img/u7986.png");
        });

        $('#box').delegate('.page','click',function () {
            var page = $(this).data('page');
            $.ajax({
                type:"get",
                url:"/community/getComment",
                data:{
                    id:{{$data['community_id']}},
                    page:page
                },
                success:function(r){
                    if (r){
                        $('#box').html(r);
                    }

                }
            })
        });
    })

</script>